home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / exampleCode / opengl / GLUT / test / test19.c < prev    next >
C/C++ Source or Header  |  1996-11-11  |  1KB  |  66 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1994. */
  3.  
  4. /* This program is freely distributable without licensing fees 
  5.    and is provided without guarantee or warrantee expressed or 
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. /* This test makes sure damaged gets set when a window is
  9.    resized smaller. */
  10.  
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13. #include <GL/glut.h>
  14.  
  15. int width = -1, height = -1;
  16. int displayCount = 0;
  17.  
  18. void
  19. done(int value)
  20. {
  21.   if (displayCount != 2) {
  22.     fprintf(stderr, "FAIL: test19, damage expected\n");
  23.     exit(1);
  24.   }
  25.   fprintf(stderr, "PASS: test19\n");
  26.   exit(0);
  27. }
  28.  
  29. void
  30. reshape(int w, int h)
  31. {
  32.   printf("window reshaped: w=%d, h=%d\n", w, h);
  33.   width = w;
  34.   height = h;
  35. }
  36.  
  37. void
  38. display(void)
  39. {
  40.   if (glutLayerGet(GLUT_NORMAL_DAMAGED) == 0) {
  41.     fprintf(stderr, "FAIL: test19, damage expected\n");
  42.     exit(1);
  43.   }
  44.   displayCount++;
  45.   if (width == -1 || height == -1) {
  46.     fprintf(stderr, "FAIL: test19, reshape not called\n");
  47.     exit(1);
  48.   }
  49.   glClear(GL_COLOR_BUFFER_BIT);
  50.   if (displayCount == 1) {
  51.     glutReshapeWindow(width / 2, height / 2);
  52.     glutTimerFunc(1000, done, 0);
  53.   }
  54. }
  55.  
  56. int
  57. main(int argc, char **argv)
  58. {
  59.   glutInit(&argc, argv);
  60.   glutCreateWindow("test19");
  61.   glutDisplayFunc(display);
  62.   glutReshapeFunc(reshape);
  63.   glutMainLoop();
  64.   return 0;             /* ANSI C requires main to return int. */
  65. }
  66.